#include "mywidget.h"
#include "ui_mywidget.h"

myWidget::myWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::myWidget)
{
    ui->setupUi(this);
     //封装两个控件的值对应，QSpinBox变化增加，QSlider变化移动，有参的信号和槽
      void (QSpinBox:: *spSignal)(int)=&QSpinBox::valueChanged;
     connect(ui->spinBox,spSignal,ui->horizontalSlider,&QSlider::setValue);
     connect(ui->horizontalSlider,&QSlider::valueChanged,ui->spinBox,&QSpinBox::setValue);
}

void  myWidget::setnum(int snum){
    ui->spinBox->setValue(snum);
}
int myWidget::getnum(void){
    return ui->spinBox->value();
}

myWidget::~myWidget()
{
    delete ui;
}
